java导出的文件名带正斜杠,常见问题:文件名中的斜杠??? | 您所在的位置:网站首页 › jszip 压缩文件 › java导出的文件名带正斜杠,常见问题:文件名中的斜杠??? |
Why does the faq make this statement regarding slashes in paths: "This is because the library routines on these operating systems handle "/" and "\" interchangeably. " http://www.parashift.com/c++-faq-lit...html#faq-15.16 This seems like completely the wrong answer for this question. Rather than saying that you should use forward slash as a delimiter, it should say something to the effect of "refer to your operating system documentation on how to specify paths/subdirectories, remembering that in a string literal in C++ the back-slash (\) character modifies the following character, and therefore operating systems that use a backslash as a directory delimiter should be encoded as ''\\''. Comments? 解决方案 Julie spoke thus: This seems like completely the wrong answer for this question. Rather than saying that you should use forward slash as a delimiter, it should say something to the effect of "refer to your operating system documentation on how to specify paths/subdirectories, remembering that in a string literal in C++ the back-slash (\) character modifies the following character, and therefore operating systems that use a backslash as a directory delimiter should be encoded as ''\\''. FWIW, I''ve been bitten by / vs. \ issues in the past. Whether or not that behavior is conforming, I''d say it''s safer just to use the delimiter that the implementation prefers... -- Christopher Benson-Manica | I *should* know what I''m talking about - if I ataru(at)cyberspace.org | don''t, I need to know. Flames welcome. Julie wrote: Why does the faq make this statement regarding slashes in paths: "This is because the library routines on these operating systems handle "/" and "\" interchangeably. " http://www.parashift.com/c++-faq-lit...html#faq-15.16 This seems like completely the wrong answer for this question. Rather than saying that you should use forward slash as a delimiter, it should say something to the effect of "refer to your operating system documentation on how to specify paths/subdirectories, remembering that in a string literal in C++ the back-slash (\) character modifies the following character, and therefore operating systems that use a backslash as a directory delimiter should be encoded as ''\\''. It doesn''t seem likely that using ''/'' instead of ''\\'' will /hurt/ you in any way -- and it should make the code a bit more portable. For full portability, I don''t think you can assume anything about the directory separator (or even assume that there are directories, but no one is likely to complain if you decide to only support systems that support directories, I think). -Kevin -- My email address is valid, but changes periodically. To contact me please use the address from a recent posting. Julie wrote: Why does the faq make this statement regarding slashes in paths: "This is because the library routines on these operating systems handle "/" and "\" interchangeably. " http://www.parashift.com/c++-faq-lit...html#faq-15.16 This seems like completely the wrong answer for this question. Rather than saying that you should use forward slash as a delimiter, it should say something to the effect of "refer to your operating system documentation on how to specify paths/subdirectories, remembering that in a string literal in C++ the back-slash (\) character modifies the following character, and therefore operating systems that use a backslash as a directory delimiter should be encoded as ''\\''. Comments? Using the forward slash is very portable. As the answer correctly states, even operating systems that natively use "\" (Windows, DOS, OS/2, etc.) provide library routines that understand "/". So the "/" is very portable -- certainly better than "\". So I wouldn''t call it "completely the wrong answer," but I would add a disclaimer that nothing is guaranteed by the standard about directory delimiters. In fact, nothing is guaranteed about a directories (or even a filesystem) existing at all. |
CopyRight 2018-2019 实验室设备网 版权所有 |